﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MicroBenchmarks.MultiMethodsInLoop
{
    /// <summary>
    /// A class where the desired method-call has to be called in a loop, but the loop includes
    /// some other method also to be called. An FSM is required to iterate those many loops
    /// </summary>
    public class MultiMethodsInLoop
    {
        private int member1;
        private bool localState;

        bool m1set, m2set;

        public MultiMethodsInLoop()
        {
            localState = false;
            m1set = true;
            m2set = false;
        }
        
        public bool InternalState 
        {
            get {
                return localState;
            }
        }

        private void SetLocalState()
        {
            if (member1 == 5)
                localState = true;
        }

        public void IncrM1()
        {
            if (!m2set)
                throw new Exception("Member2 is not set properly");

            member1++;
            SetLocalState();
            m1set = true;
            m2set = false;
        }

        public void IncrM2()
        {
            if (!m1set)
                throw new Exception("Member1 is not set properly");

            m2set = true;
            m1set = false;
        }
    }
}
